# U-Boot: UDOO
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=4

pkgbase=uboot-udoo
pkgname=('uboot-udoo-dual' 'uboot-udoo-quad')
pkgver=2015.01
pkgrel=1
arch=('armv7h')
url="http://git.denx.de/u-boot.git/"
license=('GPL')
makedepends=('git' 'bc')
source=("ftp://ftp.denx.de/pub/u-boot/u-boot-${pkgver}.tar.bz2"
        '0001-arch-linux-arm-modifications.patch')
md5sums=('7f08dc9e98a71652bd6968888ed6ec95'
         '85e269e9211ea5ed2d9ccc7bb8c8d5d7')

prepare() {
  cd u-boot-${pkgver}

  git apply ../0001-arch-linux-arm-modifications.patch
}

build() {
  cd u-boot-${pkgver}
  
  unset CFLAGS CXXFLAGS LDFLAGS
  
  mkdir bins
  for i in dl quad; do
    make distclean
    make udoo_${i}_config
    make
    mv u-boot.imx bins/u-boot-${i}.imx
  done
}

package_uboot-udoo-dual() {
  pkgdesc="U-Boot for UDOO Dual"
  conflicts=('uboot-udoo-quad')
  install=${pkgbase}.install

  mkdir -p "${pkgdir}"/boot
  cp u-boot-${pkgver}/bins/u-boot-dl.imx "${pkgdir}"/boot/u-boot.imx
}

package_uboot-udoo-quad() {
  pkgdesc="U-Boot for UDOO Quad"
  conflicts=('uboot-udoo-dual')
  install=${pkgbase}.install

  mkdir -p "${pkgdir}"/boot
  cp u-boot-${pkgver}/bins/u-boot-quad.imx "${pkgdir}"/boot/u-boot.imx
}
